package notify

import (
	 "enotify/pkg/notify/conf"
	"fmt"
)

type ISend interface {
	Send(bizType string,data []byte) (reply *SendReply)
}

type SendReply struct {
	Msg string
	Code int
	Reply string
}
func (e *SendReply) Error() string{
	return fmt.Sprintf("code:%d,msg:%s",e.Code,e.Msg)
}
func NewSendReply(code int,msg string) *SendReply{
	return &SendReply{
		Msg:   msg,
		Code:  code,
		Reply: "",
	}
}

type Task struct {
	bizType string
	data []byte
	sender ISend
}
type Sender struct {
	config *conf.Config
	wxTemplateSender *WxSender
	wxCustomerSender *WxSender
	smsSender *SMSSender
	appSender *AppSender
	queue chan Task 
	maxLen int
}

type option func(s *Sender)
func NewSender(c *conf.Config,options ...option) *Sender{
	sender := &Sender{
		config: c,
	}
	for _,op := range options {
		op(sender)
	}
	return sender
}

func (s *Sender) send(task Task) (err *SendReply){
	err = task.sender.Send(task.bizType,task.data)
	return
}
func (s *Sender) SncySend(task Task) (err error) {
	err = NewSendReply(0,"")
	return
}

